package com.创建型模式.建造者模式;

/**
 * lombok 创建对象的方式   可以一直 ...  原来这样，返回对象本身。
 */
public class BuildLombok {
    String name;
    Integer age;
    String sex;

    public BuildLombok(String name, Integer age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public BuildLombok() {
    }

    public BuildLombok Name(String name) {
        this.name = name;
        return this;
    }

    public BuildLombok Age(Integer age) {
        this.age = age;
        return this;
    }

    public BuildLombok Sex(String sex) {
        this.sex = sex;
        return this;
    }

    @Override
    public String toString() {
        return "BuildLombok{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                '}';
    }

    public static void main(String[] args) {

        BuildLombok buildLombok = new BuildLombok().Name("飞机").Sex("性感大飞机").Age(16);
        buildLombok.Name("刘亦非");
        System.out.println(buildLombok.sex);
        System.out.println(buildLombok.toString());
    }
}
